﻿using System;
using System.Collections.Generic;
using System.Text;

namespace iPdf
{
    abstract class ActionPage<ItemType, OptionType> : TataRibbonPage
    {
        protected Actor<ItemType, OptionType> actor;

        public ActionPage(bool initialize)
            :base(initialize)
        {
        }

        public ActionPage()
            : this(false)
        {
        }

        protected override void DoAction()
        {
            TataGrid grid = Global.Grid;
            int rowCnt = grid.RowsCount;
            ItemType[] items = new ItemType[rowCnt - 1];
            for (int i = 1; i < rowCnt; ++i)
            {
                items[i - 1] = GetIthActionItem(grid, i);
            }

            //do the action
            if (actor != null)
            {
                actor.Execute(items, PageOption);
            }
        }


        protected virtual OptionType PageOption
        {
            get
            {
                return default(OptionType);
            }
        }

        protected abstract ItemType GetIthActionItem(TataGrid grid, int i);

    }
}
